<?php
declare (strict_types=1);

namespace app\admin\controller\recharge;

use think\response\Json;
use app\admin\controller\Controller;
use app\admin\model\recharge\Order as OrderModel;
use app\common\enum\recharge\order\RechargeType as RechargeTypeEnum;
use app\common\enum\recharge\order\PayStatus as PayStatusEnum;
use app\common\enum\payment\Method as PaymentMethodEnum;
/**
 * 充值记录
 * Class Log
 * @package app\admin\controller\recharge
 */
class Log extends Controller
{
    /**
     * 列表
     * @return Json
     */
    public function lists(): Json
    {
        $model = new OrderModel;
        $list = $model->getList($this->request->param())->toArray();
        return $this->renderSuccess([
            'total' => $list['total'],
            'items' => $list['data']
        ]);
    }
    /**
     * 充值方式
     * @return Json
     */
    public function getRechargeType(): Json
    {
        $list = RechargeTypeEnum::data();
        $res = [];
        foreach ($list as $key => $value) {
            $res[] = $value;
        }
        return $this->renderSuccess($res);
    }
    /**
     * 支付方式
     * @return Json
     */
    public function getPaymentMethod(): Json
    {
        $list = PaymentMethodEnum::data();
        unset($list['balance']);
        $res = [];
        foreach ($list as $key => $value) {
            $res[] = $value;
        }
        return $this->renderSuccess($res);
    }
    /**
     * 支付状态
     * @return Json
     */
    public function getPayStatus(): Json
    {
        $list = PayStatusEnum::data();
        $res = [];
        foreach ($list as $key => $value) {
            $res[] = $value;
        }
        return $this->renderSuccess($res);
    }
}
